# @Time    : 2022/7/16 9:27
# @Author  : mobai
# @Email   : 3111283671@qq.com
# @File    : bjht_page.py
# @Software: PyCharm

import unittest
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
from pages.base_pageage import BasePage
from selenium.webdriver.support.select import Select
from pages.hetong_page import HeTongPage


class BjhtPage(HeTongPage):
    """编辑合同"""
    url = "http://192.168.1.151/crm/index.php?m=contract&a=edit&id=8"
    QYSJ = (By.ID, "due_time")
    LYSJ = (By.ID, "business_name")
    XZSJ = (By.CSS_SELECTOR, "#data > tr > td:nth-child(1) > input[type=radio]:nth-child(1)")
    OK = (By.XPATH, "/html/body/div[7]/div[3]/div/button[1]/span")
    FZR = (By.ID, "owner_name")
    XZFZR = (By.CSS_SELECTOR, "#d_content > tr:nth-child(3) > td:nth-child(1) > input[type=radio]")
    OK1 = (By.CSS_SELECTOR,
           "body > div:nth-child(13) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button:nth-child(1) > span")
    HTJE = (By.ID, "price")
    HTSXSJ = (By.ID, "start_date")
    HTDQSJ = (By.ID, "end_date")
    BC = (By.CSS_SELECTOR,
          "body > div.container > div.row > div > form > table > tfoot > tr > td:nth-child(2) > input.btn.btn-primary")

    def qysj(self,qysj):
        """输入签约时间"""
        self.driver.find_element(*self.QYSJ).clear()
        self.driver.find_element(*self.QYSJ).send_keys(qysj)

    def lysj(self):
        """输入来源商机"""
        self.driver.find_element(*self.LYSJ).click()  # 点击
        sleep(2)
        self.driver.find_element(*self.XZSJ).click()  # 选择商机
        self.driver.find_element(*self.OK).click()  # 点击OK

    def fzr(self):
        """输入负责人"""
        self.driver.find_element(*self.FZR).clear()  # 清空
        self.driver.find_element(*self.FZR).click()  # 点击
        sleep(1)
        self.driver.find_element(*self.XZFZR).click()  # 选择负责人
        self.driver.find_element(*self.OK1).click()  # 点击OK1

    def htje(self,htje):
        """输入合同金额"""
        self.driver.find_element(*self.HTJE).send_keys(htje)

    def htsxsj(self,htsxsj):
        """输入合同生效时间"""
        self.driver.find_element(*self.HTSXSJ).send_keys(htsxsj)

    def htdqsj(self):
        """输入合同到期时间"""
        self.driver.find_element(*self.HTDQSJ).send_keys("2022-09-10")

    def bc(self):
        """点击保存"""
        self.driver.find_element(*self.BC).click()

